/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package sdd.entities;

import java.io.Serializable;
import java.util.List;
import javax.persistence.Basic;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlTransient;

/**
 * @author asabido
 */
@Entity
@Table(name = "CUSTOMERORDER", catalog = "devSupplyDB", schema = "")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "Customerorder.findAll", query = "SELECT c FROM Customerorder c")})
public class Customerorder implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @Basic(optional = false)
    @NotNull
    @Column(name = "id")
    private Integer id;
    @Size(max = 45)
    @Column(name = "status")
    private String status;
    @Size(max = 45)
    @Column(name = "ref")
    private String ref;
    // @Max(value=?)  @Min(value=?)//if you know range of your decimal fields consider using these annotations to enforce field validation
    @Column(name = "total_value")
    private Float totalValue;
    @JoinColumn(name = "CUSTOMER_id", referencedColumnName = "id")
    @ManyToOne
    private Customer cUSTOMERid;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "customerorder")
    private List<OrderProduct> orderProductList;

    public Customerorder() {
    }

    public Customerorder(Integer id) {
        this.id = id;
    }

    public Integer getId() {
        return id;
    }

    public void setId(Integer id) {
        this.id = id;
    }

    public String getStatus() {
        return status;
    }

    public void setStatus(String status) {
        this.status = status;
    }

    public String getRef() {
        return ref;
    }

    public void setRef(String ref) {
        this.ref = ref;
    }

    public Float getTotalValue() {
        return totalValue;
    }

    public void setTotalValue(Float totalValue) {
        this.totalValue = totalValue;
    }

    public Customer getCUSTOMERid() {
        return cUSTOMERid;
    }

    public void setCUSTOMERid(Customer cUSTOMERid) {
        this.cUSTOMERid = cUSTOMERid;
    }

    @XmlTransient
    public List<OrderProduct> getOrderProductList() {
        return orderProductList;
    }

    public void setOrderProductList(List<OrderProduct> orderProductList) {
        this.orderProductList = orderProductList;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (id != null ? id.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Customerorder)) {
            return false;
        }
        Customerorder other = (Customerorder) object;
        if ((this.id == null && other.id != null) || (this.id != null && !this.id.equals(other.id))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "sdd.entities.Customerorder[ id=" + id + " ]";
    }
    
}
